home *** CD-ROM | disk | FTP | other *** search
- package com.ibm.bsf.engines.jacl;
-
- import com.ibm.bsf.BSFEngine;
- import com.ibm.bsf.BSFException;
- import com.ibm.bsf.BSFManager;
- import com.ibm.bsf.util.EngineUtils;
- import tcl.lang.Command;
- import tcl.lang.Interp;
- import tcl.lang.ReflectObject;
- import tcl.lang.TclException;
- import tcl.lang.TclObject;
-
- class BSFCommand implements Command {
- BSFManager mgr;
- BSFEngine jengine;
-
- BSFCommand(BSFManager var1, BSFEngine var2) {
- this.mgr = var1;
- this.jengine = var2;
- }
-
- public void cmdProc(Interp var1, TclObject[] var2) throws TclException {
- if (var2.length < 2) {
- var1.setResult("invalid # of args; usage: bsf lookupBean|registerBean|unregisterBean|addEventListener args");
- throw new TclException(1);
- } else {
- String var3 = var2[1].toString();
- if (var3.equals("lookupBean")) {
- if (var2.length != 3) {
- var1.setResult("invalid # of args; usage: bsf lookupBean name-of-bean");
- throw new TclException(1);
- } else {
- String var8 = var2[2].toString();
- Object var5 = this.mgr.lookupBean(var8);
- if (var5 == null) {
- var1.setResult("unknown object: " + var8);
- throw new TclException(1);
- } else {
- var1.setResult(ReflectObject.newInstance(var1, var5.getClass(), var5));
- }
- }
- } else if (var3.equals("registerBean")) {
- if (var2.length != 4) {
- var1.setResult("invalid # of args; usage: bsf registerBean name-of-bean bean");
- throw new TclException(1);
- } else {
- this.mgr.registerBean(var2[2].toString(), ReflectObject.get(var1, var2[3]));
- var1.setResult("");
- }
- } else if (var3.equals("unregisterBean")) {
- if (var2.length != 3) {
- var1.setResult("invalid # of args; usage: bsf unregisterBean name-of-bean");
- throw new TclException(1);
- } else {
- this.mgr.unregisterBean(var2[2].toString());
- var1.setResult("");
- }
- } else if (var3.equals("addEventListener")) {
- if (var2.length != 6) {
- var1.setResult("invalid # of args; usage: bsf addEventListener object event-set-name filter script-to-run");
- throw new TclException(1);
- } else {
- try {
- String var4 = var2[4].toString();
- var4 = var4.equals("") ? null : var4;
- EngineUtils.addEventListener(ReflectObject.get(var1, var2[2]), var2[3].toString(), var4, this.jengine, this.mgr, "<event-script>", 0, 0, var2[5].toString());
- } catch (BSFException var6) {
- ((Throwable)var6).printStackTrace();
- var1.setResult("got BSF exception: " + ((Throwable)var6).getMessage());
- throw new TclException(1);
- }
- }
- }
- }
- }
- }
-